<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

/**
 * @property array $account_json 收款账号
 * @property float $level_1 店长保留利润
 * @property float $level_2 组长保留利润
 * @property float $level_3 主管保留利润
 * @property float $level_4 经理保留利润
 * @property float $level_5 总经理保留利润
 * @property float $original_price 原价
 * @property float $price 价格
 * @property int $class_id 分类
 * @property int $id
 * @property int $sales 销量
 * @property int $sku 库存
 * @property string $createtime
 * @property string $description 详情
 * @property string $images 图片
 * @property string $name 名称
 * @property string $return_json 退货信息
 * @property string $spec_ids 规格
 * @property string $tags 标签
 * @property string $videos 视频
 * @mixin \think\Model
 */
class Goods extends Model
{
	protected $createTime = 'createtime';
	protected $updateTime = 'updatetime';
	protected $type = [
		'account_json'=>'json',
	];
	
	function getTagsAttr($value)
	{
		return $value?explode(',',$value):[];
    }
	
	function getImagesAttr($value)
	{
		return $value?explode(',',$value):[];
	}
	
	function getVideosAttr($value)
	{
		return $value?explode(',',$value):[];
	}
	
	function getSpecIdsAttr($value)
	{
		return $value? GoodsSpec::whereIn('id',$value)->select():[];
	}
	
	function assess()
	{
		return $this->hasMany(GoodsOrderAssess::class,'goods_id');
	}
	
}
